package tr.edu.ege.kipler.satisfiability.container;

import java.util.Set;

import tr.edu.ege.kipler.common.Copyable;
import tr.edu.ege.kipler.common.MultivalueHashMap;
import tr.edu.ege.kipler.syntax.WorldElement;

/**
 * 
 * @author İnanç Seylan
 *
 */
public class DependencyManager implements Copyable<DependencyManager> {
	private MultivalueHashMap<WorldElement, WorldConstraintSystem> dependencies = new MultivalueHashMap<WorldElement, WorldConstraintSystem>();

	public void add(WorldElement f, WorldConstraintSystem wcs) {
		dependencies.put(f, wcs);
	}

	public void addAll(WorldElement f, Set<WorldConstraintSystem> wcsSet) {
		for (WorldConstraintSystem wcs : wcsSet) {
			dependencies.put(f, wcs);
		}
	}

	public void move(WorldElement into, WorldElement from) {
		addAll(into, getDependencies(from));
	}

	public Set<WorldConstraintSystem> getDependencies(WorldElement f) {
		return dependencies.getValuesForKey(f);
	}

	public void remove(WorldElement f) {
		dependencies.remove(f);
	}

	public DependencyManager copy() {
		DependencyManager result = new DependencyManager();
		result.dependencies = dependencies.copy();
		return result;
	}

}
